//
//  LabCell.m
//  WanCaiC8
//
//  Created by tangang on 2018/2/28.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "LabCell.h"

@implementation LabCell{
    
    UIView      *lineView;
    UIView      *rightLine;
    UIView      *bottomLine;
    UIView      *leftLine;
    UIView      *topLine;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        WS(weakSelf);
        _labTitle=[[QXLable alloc]init];
        _labTitle.textAlignment=NSTextAlignmentCenter;
        [self.contentView addSubview:_labTitle];
        [_labTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(weakSelf.contentView);
        }];
        lineView=[[UIView alloc]init];
        lineView.backgroundColor=NAVCOLOR;
        lineView.hidden=YES;
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(weakSelf.contentView);
            make.bottom.equalTo(weakSelf.contentView);
            make.size.mas_equalTo(CGSizeMake(30, 2));
        }];
        
        rightLine=[[UIView alloc]init];
        rightLine.backgroundColor=DEFAULTLINECOLOR;
        rightLine.hidden=YES;
        [self.contentView addSubview:rightLine];
        [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.bottom.equalTo(weakSelf.contentView).with.offset(-.5);
            make.width.mas_equalTo(@.5);
        }];
        
        bottomLine=[[UIView alloc]init];
        bottomLine.backgroundColor=DEFAULTLINECOLOR;
        bottomLine.hidden=YES;
        [self.contentView addSubview:bottomLine];
        [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(weakSelf.contentView);
            make.height.mas_equalTo(@.7);
        }];
        
        leftLine=[[UIView alloc]init];
        leftLine.backgroundColor=DEFAULTLINECOLOR;
        leftLine.hidden=YES;
        [self.contentView addSubview:leftLine];
        [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(weakSelf.contentView);
            make.width.mas_equalTo(@.5);
        }];
        
        topLine=[[UIView alloc]init];
        topLine.backgroundColor=DEFAULTLINECOLOR;
        topLine.hidden=YES;
        [self.contentView addSubview:topLine];
        [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(weakSelf.contentView);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}

- (void)setTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    if (isSelect) {
        _labTitle.textColor=NAVCOLOR;
    }else{
        _labTitle.textColor=DEFAULTTEXTBLACKCOLOR;
    }
}

- (void)setRedTitle:(NSString *)title{
    [_labTitle setText:title];
    _labTitle.textColor=NAVCOLOR;
    [_labTitle setFont:[UIFont boldSystemFontOfSize:13]];
    rightLine.hidden=NO;
    bottomLine.hidden=NO;
}

- (void)setBGColorWithTitle:(NSString *)title{
    [_labTitle setText:title];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=3.0;
    _labTitle.backgroundColor=DEFAULTLINECOLOR;
    _labTitle.textColor=DEFAULTTEXTGDARKRAYCOLOR;
}

- (void)setBGColorWithTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=3.0;
    if (isSelect) {
        _labTitle.textColor=[UIColor whiteColor];
        _labTitle.backgroundColor=NAVCOLOR;
    }else{
        _labTitle.backgroundColor=DEFAULTBGCOLOR;
        _labTitle.textColor=DEFAULTTEXTGDARKRAYCOLOR;
    }
}


- (void)setBGColorWithTitle:(NSString *)title andCornerRadius:(float)cornerRadius andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=cornerRadius;
    if (isSelect) {
        _labTitle.textColor=[UIColor whiteColor];
        _labTitle.backgroundColor=NAVCOLOR;
    }else{
        _labTitle.backgroundColor=DEFAULTBGCOLOR;
        _labTitle.textColor=DEFAULTTEXTGDARKRAYCOLOR;
    }
}

- (void)setCircularBGColorWithTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=15.0;
    if (isSelect) {
        _labTitle.textColor=[UIColor whiteColor];
        _labTitle.backgroundColor=NAVCOLOR;
    }else{
        _labTitle.backgroundColor=[UIColor whiteColor];
        _labTitle.textColor=DEFAULTTEXTGDARKRAYCOLOR;
    }
}

- (void)setWhiteBGColorWithTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=3.0;
    _labTitle.layer.borderWidth=.7;
    if (isSelect) {
        _labTitle.layer.borderColor=NAVCOLOR.CGColor;
        _labTitle.textColor=[UIColor whiteColor];
        _labTitle.backgroundColor=NAVCOLOR;
    }else{
        _labTitle.layer.borderColor=DEFAULTTEXTGDARKRAYCOLOR.CGColor;
        _labTitle.backgroundColor=[UIColor whiteColor];
        _labTitle.textColor=DEFAULTTEXTGDARKRAYCOLOR;
    }
}

- (void)setLotteryWithTitle:(NSString *)title andLaset:(BOOL)isLast{
    [_labTitle setText:title];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=15.0;
    if (isLast) {
        _labTitle.backgroundColor=[UIColor colorWithHexString:@"#1E3FD9"];
    }else{
        if ([title isEqualToString:@"+"]) {
            _labTitle.backgroundColor=[UIColor clearColor];
        }else{
            _labTitle.backgroundColor=NAVCOLOR;
        }
    }
}

- (void)setBtnTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    _labTitle.font=[UIFont systemFontOfSize:13];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=4.0;
    _labTitle.layer.borderColor=DEFAULTLINECOLOR.CGColor;
    _labTitle.layer.borderWidth=1.0;
    if (isSelect) {
        _labTitle.backgroundColor=DEFAULTBGCOLOR;
    }else{
        _labTitle.backgroundColor=[UIColor whiteColor];
    }
}

- (void)setBGColor:(UIColor *)color andTitle:(NSString *)title andCornerRadius:(float)cornerRadius{
    [_labTitle setText:title];
    _labTitle.font=[UIFont systemFontOfSize:13];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=cornerRadius;
    _labTitle.backgroundColor=color;
}


- (void)tg_setBtnTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    

    [_labTitle setTextColor:[UIColor whiteColor]];
    
    [_labTitle mas_updateConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(5, 5, 5, 5 ));
    }];

    [_labTitle setText:title];
    
    _labTitle.font=[UIFont systemFontOfSize:13];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=5.0;
    _labTitle.layer.borderWidth=1.0;
    
    if (isSelect) {
        _labTitle.backgroundColor=[UIColor colorWithHexString:@"#b82828"];
        _labTitle.layer.borderColor=[UIColor colorWithHexString:@"#b82828"].CGColor;

    }else{
        _labTitle.backgroundColor=[UIColor clearColor];
        _labTitle.layer.borderColor=[UIColor clearColor].CGColor;

    }
    
}

- (void)setLinColorWithTitleWithTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    _labTitle.layer.masksToBounds=YES;
    _labTitle.layer.cornerRadius=3.0;
    _labTitle.backgroundColor=DEFAULTBGCOLOR;
    _labTitle.textColor=DEFAULTTEXTGDARKRAYCOLOR;
    if (isSelect) {
        _labTitle.layer.borderColor=NAVCOLOR.CGColor;
        _labTitle.layer.borderWidth=1.0;
    }else{
        _labTitle.layer.borderColor=DEFAULTLINECOLOR.CGColor;
        _labTitle.layer.borderWidth=1.0;
    }
}

- (void)setBottomLineTitle:(NSString *)title andIsSelect:(BOOL)isSelect{
    [_labTitle setText:title];
    lineView.hidden=!isSelect;
    if (isSelect) {
        _labTitle.textColor=NAVCOLOR;
        
    }else{
        _labTitle.textColor=DEFAULTTEXTBLACKCOLOR;
    }
    
}

- (void)setLeftTitle:(NSString *)title andLeft:(CGFloat)left{
    [_labTitle setText:title];
    _labTitle.textAlignment=NSTextAlignmentLeft;
    rightLine.hidden=NO;
    bottomLine.hidden=NO;
    [_labTitle mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(0, left, 0, 0));
    }];
}

- (void)setAllLineTitle:(NSString *)title andShowRightLine:(BOOL)isShow andShowBottomLine:(BOOL)isBottomLine{
    [_labTitle setText:title];
    _labTitle.textAlignment=NSTextAlignmentCenter;
    rightLine.hidden=NO;
    bottomLine.hidden=isBottomLine;
    leftLine.hidden=isShow;
    topLine.hidden=NO;
}

- (void)setLineTitle:(NSString *)title{
    [_labTitle setText:title];
    rightLine.hidden=NO;
    bottomLine.hidden=NO;
    topLine.hidden=YES;
}

- (void)showTopLine{
    topLine.hidden=NO;
}

@end
